<template>
	<view class="bb" v-for="(v,i) in data">
		<view>用药人</view>
		<view>用药人姓名：<span>{{b.yyr_name}}</span></view>
		<view>关系：<span>{{b.yyr_guanxi}}</span></view>
		<view>身份证号：<span>{{b.yyr_shengfenzheng}}</span></view>
		<view ></view>
		<view>性别：<span>{{b.yyr_sex}}</span></view>
		<view>手机号：<span>{{b.yyr_tel}}</span></view>
		<view>疾病史：<span>{{b.yyr_bingshi}}</span></view>
		<view>处方单</view>
		<view v-for="(v,i) in v.cf_imgsrc">
			<image mode="widthFix" :src='IP+v' ></image>
		</view>
		<view @click="chakan(v.cf_imgsrc)" class="chakanchufang">查看处方</view>
		<view></view>
	</view>
	<view v-if="c==1" class="zanwu">此用药人暂无处方</view>
</template>

<script>
	import {
		toRefs,
		onMounted,
		reactive,
		computed
	} from 'vue'
	import store from '../../store/index.js'
	import http from '../../utils/http.js'
	export default {
		setup() {
			let data = reactive({
				c:0,
				a: 1,
				b: {},
				IP: '',
				data: [],
				chufang: [],
				chufangdizhi: '',
				img1:'',
				img2:'',
				chakan: (a) => {
					let b =[]
					 for(let i=0;i<a.length;i++){
						 b.push(data.IP + a[i])
					 }
					console.log(b)
					uni.previewImage({
						urls:b,

					});
				}
			})
			onMounted(() => {
				data.IP = store.state.IP //本地地址
				data.b = store.state.dizhi.b //用药人的信息
				
				let a = store.state.dizhi.b.yyr_id //用药人的id
				
				http({ //找到用药人的处方
					url: '/SetBasic/getchufang',
					method: 'get',
					data: {
						id: a
					}
				}).then((res) => {
					data.data = res.data.data
					for(let i=0;i<data.data.length;i++){
						let str=data.data[i].cf_imgsrc
						if(str.indexOf(",") != -1){
							data.img1=str.split(',')[0]
							data.img2=str.split(',')[1]
							let arr=[]
							arr.push(data.img1)
							arr.push(data.img2)
							data.data[i].cf_imgsrc=arr
						}else{
							let arr=[]
							arr.push(data.data[i].cf_imgsrc)
							data.data[i].cf_imgsrc=arr
						}
					}
					if(data.data.length==0){
						data.c=1
					}else{
						data.c=0
					}
				})
			})
			return {
				...toRefs(data)
			}
		}
	}
	
</script>

<style lang="less">
	.bb {

		padding: 0rpx 30rpx;
		box-sizing: border-box;

		image {
			width: 690rpx;
			margin: 20rpx 0;
		}

		>view {
			margin: 20rpx 0;

			&:nth-child(1) {
				font-size: 45rpx;
				margin: 40rpx 0;
			}

			
			&:last-child {
				clear: both;
			}

		}
	}
	.zanwu{
		display: flex;
		justify-content: center;
		font-size: 40rpx;
		margin-top: 100rpx;
	}
	.chakanchufang {
		text-align: center;
		width: 200rpx;
		border: 1rpx solid #DA2222;
		padding: 15rpx;
		float: right;
		margin-bottom: 40rpx !important;
	
	}
	
</style>
